<template>
	<el-dialog width="40%" visible :show-close="false" :modal-append-to-body="false" class="wrap" >
		 <div class="bt">配件详情</div>
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index:10;"></i>
		<el-form label-width="100px" class="form">
			<el-form-item label="物品分类">
				  <el-input v-model="form.flmc" :readonly='true' icon="info" class="select-block"></el-input>
			</el-form-item>
			<el-form-item label="物品名称">
				  <el-input v-model="form.wpmc" :readonly='true' icon="info" class="select-block"></el-input>
			</el-form-item>
		</el-form>
		<hr />
		<!--<h1>拆分可得以下物品</h1>-->
		 <el-table :data="dataList" stripe style="width: 100%">
					<el-table-column prop="pjmc" label="配件名称"></el-table-column>
					<el-table-column prop="cnt" label="库存数量"></el-table-column>
				  </el-table>
			<!--<ul v-for="i in pjlist" v-if="cf">
			<li>{{i.mc}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{i.jg}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{i.dw}}</li>
		</ul>
		<ul v-for="i in pjlist" v-if="hb">
			<h1>合并可得以下物品</h1>
			<li>{{i.mc}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{i.jg}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{i.dw}}</li>
		</ul>-->
		<div style="width: 100%; text-align: center;">
			<el-button type="primary" class="submit" @click="cancel">确定</el-button>
		</div>
	</el-dialog>
</template>

<script type="text/javascript">
	import qs from 'qs'
	export default {
		props: ['params'],
		data() {
			return {
				hb:false,
				cf:false,
				form: {
					wpmc:'',
					flmc:'',
					id:'',
				},
				title:'',
				cfsl:'',
				bz:'',
				pjlist:[],
				dataList:[],
			}
		},
		created() {
			console.log(this.params,110)
			this.form = this.params.row
			if(this.params.row.ltype == "cf"){
				this.cf=true
				this.hb=false
				this.title = "拆分"
			}
			if(this.params.row.ltype == "hb"){
				this.cf=false
				this.hb=true
				this.title = "合并"
			}
			this.loadinfo();
			this.loadinfo2();
		},
		methods: {
			submit(){
				if(!this.cfsl){
					this.$message.warning("请输入拆分数量!");
					return
				}
				 var logininfo = JSON.parse(localStorage.logininfo);
	             this.searchLoading = true;
	             var params2 = qs.stringify({
                      xxid:logininfo.xxid,
					  yhid:logininfo.id,
					  wpid:this.form.id,
					  cfcnt:this.cfsl,
					  note:this.bz,
	             })
             //执行
                 this.axios.post(this.$store.state.api + 'wpfx/web_savewpcfhbcfinfo',  params2 )
                 .then(res => {
                 	this.$message.success("拆分成功!");
					this.$emit('close', { type: 'add', cancel: true });
                 }).catch(res => {
					this.$message.warning("服务器异常");
			 				this.$emit('close', { type: 'add', cancel: true });
				})		
			},
			loadinfo(){
				 var logininfo = JSON.parse(localStorage.logininfo);
	             this.searchLoading = true;
	             var params2 = qs.stringify({
                      xxid:logininfo.xxid,
					  yhid:logininfo.id,
					  wpid:this.form.id
	             })
             //执行
                 this.axios.post(this.$store.state.api + 'wpfx/web_getwpcfhbpjlist',  params2 )
                 .then(res => {
//               	console.log(res,99988811111111)
                 	this.pjlist = res.data.data.list
                 }).catch(res => {
					this.$message.warning("服务器异常");
			 				this.$emit('close', { type: 'info', cancel: true });
				})			
				
			},
			loadinfo2(){
				 var logininfo = JSON.parse(localStorage.logininfo);
	             this.searchLoading = true;
	             var params2 = qs.stringify({
					  wpid:this.form.id
	             })
             //执行
                 this.axios.post(this.$store.state.api + 'wpfx/getpjxx',  params2 )
                 .then(res => {
//               	console.log(res,'sssssssss')
                 	this.dataList = res.data.data.list
                 }).catch(res => {
					this.$message.warning("服务器异常");
				})			
			},
			cancel() {
				this.$emit('close', { type: 'info', cancel: true })
			}
		}
	}
</script>

<style lang="less" scoped>
.wrap {
	/*text-align: center;*/
}
.bt{
		position: absolute;
		width: 100%;
		height: 50px;
		margin: 0 auto;
		top: 0;
		left: 0;
		background: #50BFFF;
		color:white;
		text-align:left;
		line-height: 50px;
		font-size: 17px;
		padding-left: 15px;
	}
ul{
	width: 100%;
	li{
		width: 100%;
		height: 30px;
		margin-left: 30px;
		line-height: 30px;
	}
}
.form {
	text-align: left;
	margin-top: 20px;
}
 .input {
					width: 300px;
					display: inline-block;
			}
.select-block {
	display: block;
	width: 85%;
}
.submit {
	width: 120px;
}
.el-form-item {
    margin-bottom: 10px;
}
</style>
